Skip to content

feat: add new client.getTransactionStatus() method#3645

Merged
brianc merged 7 commits into
brianc:masterfrom
panga:client-get-transaction-status
May 11, 2026
Merged

feat: add new client.getTransactionStatus() method#3645
brianc merged 7 commits into
brianc:masterfrom
panga:client-get-transaction-status

Conversation

@panga
Copy link
Copy Markdown
Contributor

@panga panga commented Apr 1, 2026

  • Add _txStatus tracking to pg.Client, populated from PostgreSQL's ReadyForQuery message.
  • Add a new client.getTransactionStatus() method to return the _txStatus value.

Note: Split from #3597

panga added 3 commits April 1, 2026 08:37
Adds a new public method to retrieve the current transaction status
of the client connection. Returns 'I' (idle), 'T' (in transaction),
'E' (error/aborted), or null (initial state/native client).

The transaction status is tracked from PostgreSQL's ReadyForQuery
message after each query completes.

Native client returns null as it does not support this feature yet.
- Add getTransactionStatus() to pg-native using libpq's
  PQtransactionStatus() with status mapping (0->I, 2->T, 3->E)
- Update pg native client wrapper to delegate to pg-native
- Remove native guard from txstatus tests (now runs in both modes)
- Bump libpq to ^1.10.0 for transactionStatus() binding support
Comment thread docs/pages/apis/client.mdx Outdated
Comment thread docs/pages/apis/client.mdx Outdated
@panga panga requested a review from charmander April 13, 2026 17:23
@brianc
Copy link
Copy Markdown
Owner

brianc commented May 11, 2026

welp after an embarrassingly long delay I want to say thank you both for the PR and your patience! I am gonna merge & release this. Sorry 🤦 - I will push this out to npm pronto.

@brianc brianc merged commit 939725e into brianc:master May 11, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants